<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
       <mycom :msg="msg" @my-event=""xyz></mycom>
    </div>
    <script>
        var component1= {
            props:['msg'],
            data(){
                return{
                    commsg:'组件数据'
                }
            },
            template:`
            <div>
                <p>我是组件</P>
                <span>{{msg}}</span>
                <button @click="abc">发送</button>
            </div>
                `,
                methods:{
                    abc(){
                        this.$emit('my-event',this.commsg)
                    }
                }
        }
        var vm = new Vue({
            el: '#app',
            data: {
                msg:'你好子组件'
            },
            methods: {
                xyz(val){
                    console.log(val)
                }
            },
            components:{
                'mycom':component1
            }
               

               })
            
        
    </script>
</body>

</html>
